package com.swt.service.impl.W_impl;

import com.swt.dao.impl.W_impl.ImagesDaoImpl;
import com.swt.domain.Image;
import com.swt.service.W_service.ImageService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ImageServiceImpl implements ImageService {
    @Resource
    private ImagesDaoImpl imagesDao;


    /**
     *保存图片
     * */
    @Override
    @Transactional
    public void saveImage(Image image) {
        imagesDao.saveImage(image);
    }


    /**
     *查询所有图片
     **/
    @Override
    public List<Image> listToAll(int page) {
        return imagesDao.listToAll(page);
    }


    /**
     * 删除图片
     * */
    @Override
    @Transactional
    public void delete(Image image) {
        imagesDao.delete(image);
    }


    /**
     * 改变图片状态
     * */
    @Override
    @Transactional
    public void changeStatus(Image image) {
        imagesDao.changeStatus(image);
    }

    /**
     * 根据时间查询图片
     * */
    @Override
    public List<Image> search(String logmin, String logmax) {
        return imagesDao.search(logmin,logmax);
    }

    /**
     * 查询数据库中状态为“已发布”的数量
     * */
    public String count(){
        return imagesDao.count();
    }
}
